<template>
  <div>
    <SelfTitle :userName="username" :infoEdit="false"></SelfTitle>
    <div class="manageContent">
      <!-- 头部搜索框 -->
      <div class="manageSearch">
        <el-input placeholder="请输入要输入的内容" class="firstInput"></el-input>
        <el-input placeholder="请输入姓名" class="secondInput"></el-input>
        <el-button>搜索</el-button>
        <el-button class="cancelBtn">取消</el-button>
        <el-button @click="enterProject">我的项目</el-button>
        <el-button @click="seeReq">查看需求</el-button>
        <el-button @click="createUser" v-if="userType == 13">创建用户</el-button>
      </div>
      <!-- 企业用户 -->
      <div class="tableBox">
        <div class="table-header-title">
          <i class="el-icon-user-solid"></i>
          <span>企业用户</span>
          <span
            @click="
              exportUser(
                'http://112.124.67.43:8088/iot/enterpriseuser/export',
                '企业用户'
              )
            "
          >
            导出
            <i class="el-icon-s-unfold"></i>
          </span>
        </div>
        <el-table
          :data="isShowMoreStatus[0].isShow ? enterpriseData : smEnterpriseData"
          style="width: 100%"
          :header-cell-style="{
            background: '#E9E9E9',
            color: '#606266',
            fontWeight: 600,
          }"
          class="el-table-isShow"
        >
          <el-table-column label="序号" width="80" type="index" align="center">
          </el-table-column>
          <el-table-column prop="username" label="用户名" width="120" align="center">
          </el-table-column>
          <el-table-column
            prop="userInfo.enterpriseName"
            label="公司名称"
            width="120"
            align="center"
          >
          </el-table-column>
          <el-table-column
            prop="userInfo.industry"
            label="所属行业"
            width="120"
            align="center"
          >
          </el-table-column>
          <el-table-column
            prop="userInfo.type"
            label="公司性质"
            width="120"
            align="center"
          >
          </el-table-column>
          <el-table-column
            prop="userInfo.contactUser"
            label="联系人"
            width="120"
            align="center"
          >
          </el-table-column>
          <el-table-column prop="email" label="邮箱" width="120" align="center">
          </el-table-column>
          <el-table-column prop="telephone" label="手机号" width="120" align="center">
          </el-table-column>
          <el-table-column
            prop="userInfo.address"
            label="联系地址"
            width="120"
            align="center"
          >
          </el-table-column>
          <el-table-column
            prop="userInfo.billingName"
            label="开票名称"
            width="120"
            align="center"
          >
          </el-table-column>
          <el-table-column
            prop="userInfo.taxNo"
            label="增值税登记号"
            align="center"
            style="display: none"
          >
          </el-table-column>
          <el-table-column prop="" label="（管理员）测评" align="center">
            <template slot-scope="scope">
              <div @click="companyAssess(scope.row.id)">
                <i class="el-icon-remove-outline" style="font-size: 20px"></i>
              </div>
            </template>
          </el-table-column>
          <el-table-column label="操作" width="120" align="center">
            <template slot-scope="scope">
              <el-button @click="motifyUserInfo(scope.row.id, 1)" type="text"
                >修改</el-button
              >
              <el-button @click="deleteManageUser(scope.row.id)" type="text"
                >删除</el-button
              >
              <el-button
                size="mini"
                @click="findShopFans(scope.row.id, 1)"
                type="text"
                v-if="scope.row.status === 0"
                >禁用</el-button
              >
              <el-button
                size="mini"
                @click="findShopFans(scope.row.id, 0)"
                type="text"
                v-else
                >解除禁用</el-button
              >
            </template>
          </el-table-column>
        </el-table>

        <ul class="ul-isShowMob">
          <li
            v-for="(item, index) in isShowMoreStatus[0].isShow
              ? enterpriseData
              : smEnterpriseData"
            :key="'comparyMob' + index"
            @click="enterMoreUserInfo(item.id, 1)"
          >
            <i class="el-icon-user"></i>
            <span>{{ item.industry }}</span>
          </li>
        </ul>

        <div class="table-bottoms">
          <span v-if="!isShowMoreStatus[0].isShow" @click="seeMore(0)">...</span>
          <span v-else @click="seeMore(0)" class="el-icon-upload2"></span>
        </div>
      </div>

      <!-- 合作伙伴 -->
      <div class="tableBox">
        <div class="table-header-title">
          <i class="el-icon-user-solid"></i>
          <span>合作伙伴</span>
          <span
            @click="
              exportUser(
                'http://112.124.67.43:8088/iot/cooperativeuser/export',
                '合作伙伴'
              )
            "
          >
            导出
            <i class="el-icon-s-unfold"></i>
          </span>
        </div>
        <el-table
          :data="isShowMoreStatus[1].isShow ? cooperativeData : smCooperativeData"
          style="width: 100%"
          :header-cell-style="{
            background: '#E9E9E9',
            color: '#606266',
            fontWeight: 600,
          }"
          class="el-table-isShow"
        >
          <el-table-column label="序号" width="80" type="index" align="center">
          </el-table-column>
          <el-table-column prop="username" label="企业名称" width="120" align="center">
          </el-table-column>
          <el-table-column
            prop="userInfo.industry"
            label="所属行业"
            width="120"
            align="center"
          >
          </el-table-column>
          <el-table-column
            prop="userInfo.staffSize"
            label="人员规模"
            width="120"
            align="center"
          >
          </el-table-column>
          <el-table-column
            prop="userInfo.serviceContent"
            label="服务内容"
            width="120"
            align="center"
          >
          </el-table-column>
          <el-table-column prop="userInfo.serviceProduct" label="服务产品" align="center">
          </el-table-column>
          <el-table-column prop="logoUrl" label="企业logo" align="center">
            <template slot-scope="scope">
              <div>
                <img :src="scope.row.userInfo.logoUrl" alt="" width="100px" />
              </div>
            </template>
          </el-table-column>
          <el-table-column prop="userInfo.address" label="联系地址" align="center">
          </el-table-column>
          <el-table-column prop="userInfo.name" label="联系人" align="center">
          </el-table-column>
          <el-table-column prop="email" label="邮箱" align="center"> </el-table-column>
          <el-table-column prop="telephone" label="电话" align="center">
          </el-table-column>
          <el-table-column prop="work" label="操作" width="120" align="center">
            <template slot-scope="scope">
              <el-button @click="motifyUserInfo(scope.row.id, 2)" type="text"
                >修改</el-button
              >
              <el-button @click="deleteManageUser(scope.row.id)" type="text"
                >删除</el-button
              >
              <el-button
                size="mini"
                @click="findShopFans(scope.row.id, 1)"
                type="text"
                v-if="scope.row.status === 0"
                >禁用</el-button
              >
              <el-button
                size="mini"
                @click="findShopFans(scope.row.id, 0)"
                type="text"
                v-else
                >解除禁用</el-button
              >
            </template>
          </el-table-column>
        </el-table>

        <ul class="ul-isShowMob">
          <li
            v-for="(item, index) in isShowMoreStatus[1].isShow
              ? cooperativeData
              : smCooperativeData"
            :key="'cooperMob' + index"
            @click="enterMoreUserInfo(item.id, 2)"
            class="cooperUserLi"
          >
            <i class="el-icon-user"></i>
            <span>{{ item.name }}</span>
          </li>
        </ul>

        <div class="table-bottoms">
          <span v-if="!isShowMoreStatus[1].isShow" @click="seeMore(1)">...</span>
          <span v-else @click="seeMore(1)" class="el-icon-upload2"></span>
        </div>
      </div>

      <!-- 合作伙伴的个人顾问 -->
      <div class="tableBox">
        <div class="table-header-title">
          <i class="el-icon-user-solid"></i>
          <span>合作伙伴的个人顾问</span>
          <span
            @click="
              exportUser(
                'http://112.124.67.43:8088/iot/cooperativeuser/exportRelation',
                '合作伙伴下的个人顾问'
              )
            "
          >
            导出
            <i class="el-icon-s-unfold"></i>
          </span>
        </div>
        <el-table
          :data="isShowMoreStatus[2].isShow ? allCooperPersonData : smAllCooperPersonData"
          style="width: 100%"
          :header-cell-style="{
            background: '#E9E9E9',
            color: '#606266',
            fontWeight: 600,
          }"
          class="el-table-isShow"
        >
          <el-table-column label="序号" width="60" type="index" align="center">
          </el-table-column>
          <el-table-column prop="username" label="用户名" width="80" align="center">
          </el-table-column>
          <el-table-column prop="name" label="姓名" width="80" align="center">
          </el-table-column>
          <el-table-column prop="cooperName" label="所属企业" width="80" align="center">
          </el-table-column>
          <el-table-column prop="industry" label="所属行业" width="80" align="center">
          </el-table-column>
          <el-table-column prop="brithday" label="出生日期" width="120" align="center">
          </el-table-column>
          <el-table-column prop="education" label="学历" width="120" align="center">
          </el-table-column>
          <el-table-column
            prop="graduatedFrom"
            label="毕业院校"
            width="120"
            align="center"
          >
          </el-table-column>
          <el-table-column prop="major" label="专业" align="center"> </el-table-column>
          <el-table-column prop="photoUrl" label="照片" align="center">
            <template slot-scope="scope">
              <div>
                <img :src="scope.row.photoUrl" alt="" width="100px" />
              </div>
            </template>
          </el-table-column>
          <el-table-column prop="serviceDirection" label="服务方向" align="center">
          </el-table-column>
          <el-table-column prop="industryExperience" label="从业经验" align="center">
          </el-table-column>
          <el-table-column prop="bmi_history" label="从业年限" align="center">
          </el-table-column>
          <el-table-column prop="expertise" label="擅长领域" align="center">
          </el-table-column>
          <el-table-column prop="email" label="邮箱" align="center"> </el-table-column>
          <el-table-column prop="telephone" label="手机号" align="center">
          </el-table-column>
          <el-table-column label="（管理员）测评" align="center">
            <template slot-scope="scope">
              <div @click="personAssess(scope.row.id)">
                <i class="el-icon-remove-outline" style="font-size: 20px"></i>
              </div>
            </template>
          </el-table-column>
          <el-table-column prop="work" label="操作" width="120" align="center">
            <template slot-scope="scope">
              <el-button @click="motifyUserInfo(scope.row.id, 3)" type="text"
                >修改</el-button
              >
              <el-button @click="deleteManageUser(scope.row.id)" type="text"
                >删除</el-button
              >
              <el-button
                size="mini"
                @click="findShopFans(scope.row.id, 1)"
                type="text"
                v-if="scope.row.status === 0"
                >禁用</el-button
              >
              <el-button
                size="mini"
                @click="findShopFans(scope.row.id, 0)"
                type="text"
                v-else
                >取消禁用</el-button
              >
            </template>
          </el-table-column>
        </el-table>

        <ul class="ul-isShowMob">
          <li
            v-for="(item, index) in isShowMoreStatus[2].isShow
              ? allCooperPersonData
              : smAllCooperPersonData"
            :key="'comparyMob' + index"
            @click="enterMoreUserInfo(item.id, 3)"
          >
            <i class="el-icon-user"></i>
            <span>{{ item.name }}</span>
          </li>
        </ul>
        <div class="table-bottoms">
          <span v-if="!isShowMoreStatus[2].isShow" @click="seeMore(2)">...</span>
          <span v-else @click="seeMore(2)" class="el-icon-upload2"></span>
        </div>
      </div>

      <!-- 个人顾问 -->
      <div class="tableBox">
        <div class="table-header-title">
          <i class="el-icon-user-solid"></i>
          <span>个人顾问</span>
          <span
            @click="
              exportUser('http://112.124.67.43:8088/iot/personaluser/export', '个人顾问')
            "
          >
            导出
            <i class="el-icon-s-unfold"></i>
          </span>
        </div>
        <el-table
          :data="isShowMoreStatus[3].isShow ? personaluserData : smPersonaluserData"
          style="width: 100%"
          :header-cell-style="{
            background: '#E9E9E9',
            color: '#606266',
            fontWeight: 600,
          }"
          class="el-table-isShow"
        >
          <el-table-column label="序号" width="60" type="index" align="center">
          </el-table-column>
          <el-table-column prop="username" label="用户名" width="120" align="center">
          </el-table-column>
          <el-table-column prop="name" label="姓名" width="120" align="center">
          </el-table-column>
          <el-table-column
            prop="userInfo.brithday"
            label="出生日期"
            width="120"
            align="center"
          >
          </el-table-column>
          <el-table-column
            prop="userInfo.education"
            label="学历"
            width="120"
            align="center"
          >
          </el-table-column>
          <el-table-column
            prop="userInfo.graduatedFrom"
            label="毕业院校"
            width="120"
            align="center"
          >
          </el-table-column>
          <el-table-column prop="userInfo.major" label="专业" align="center">
          </el-table-column>
          <el-table-column prop="userInfo.photoUrl" label="照片" align="center">
            <template slot-scope="scope">
              <div>
                <img :src="scope.row.userInfo.photoUrl" alt="" />
              </div>
            </template>
          </el-table-column>
          <el-table-column
            prop="userInfo.serviceDirection"
            label="服务方向"
            align="center"
          >
          </el-table-column>
          <el-table-column
            prop="userInfo.industryExperience"
            label="从业经验"
            align="center"
          >
          </el-table-column>
          <el-table-column prop="userInfo.bmi_history" label="从业年限" align="center">
          </el-table-column>
          <el-table-column prop="userInfo.expertise" label="擅长领域" align="center">
          </el-table-column>
          <el-table-column prop="email" label="邮箱" align="center"> </el-table-column>
          <el-table-column prop="telephone" label="手机号" align="center">
          </el-table-column>
          <el-table-column label="（管理员）测评" align="center">
            <template slot-scope="scope">
              <div @click="personAssess(scope.row.id)">
                <i class="el-icon-remove-outline" style="font-size: 20px"></i>
              </div>
            </template>
          </el-table-column>
          <el-table-column prop="work" label="操作" width="120" align="center">
            <template slot-scope="scope">
              <el-button @click="motifyUserInfo(scope.row.id, 4)" type="text"
                >修改</el-button
              >
              <el-button @click="deleteManageUser(scope.row.id)" type="text"
                >删除</el-button
              >
              <el-button
                size="mini"
                @click="findShopFans(scope.row.id, 1)"
                type="text"
                v-if="scope.row.status === 0"
                >禁用</el-button
              >
              <el-button
                size="mini"
                @click="findShopFans(scope.row.id, 0)"
                type="text"
                v-else
                >取消禁用</el-button
              >
            </template>
          </el-table-column>
        </el-table>

        <ul class="ul-isShowMob">
          <li
            v-for="(item, index) in isShowMoreStatus[3].isShow
              ? personaluserData
              : smPersonaluserData"
            :key="'comparyMob' + index"
            @click="enterMoreUserInfo(item.id, 3)"
          >
            <i class="el-icon-user"></i>
            <span>{{ item.name }}</span>
          </li>
        </ul>
        <div class="table-bottoms">
          <span v-if="!isShowMoreStatus[3].isShow" @click="seeMore(3)">...</span>
          <span v-else @click="seeMore(3)" class="el-icon-upload2"></span>
        </div>
      </div>

      <!-- 企业评分对话框 -->
      <el-dialog :visible.sync="companyAssessVisible" width="40%" class="AssessStyle">
        <h2>企业评分</h2>
        <ul>
          <li v-for="(item, index) in companyAssessTitle" :key="'compAss' + index">
            <span>{{ item.title }}</span>
            <el-rate v-model="item.value"> </el-rate>
          </li>
        </ul>
        <div class="btnBox">
          <el-button size="mini" type="primary" @click="saveCompanyAccess"
            >保 存</el-button
          >
          <el-button type="primary" size="mini" @click="companyAssessVisible = false"
            >取 消</el-button
          >
        </div>
      </el-dialog>

      <!-- 个人评分 -->
      <el-dialog
        :visible.sync="personAssessVisible"
        width="60%"
        class="personAssessStyle"
      >
        <h2>某某评分</h2>

        <ul>
          <li
            v-for="(item, index) in allSkillAccess"
            :key="'person' + index"
            @click="checkDetailAccess(index)"
          >
            <span :class="{ isChecked: currentIndex === index }">{{
              item ? item.textName : ""
            }}</span>
          </li>
        </ul>
        <!-- 评分详情 -->
        <div class="accessDetailTitle">
          {{ allSkillAccess[currentIndex] ? allSkillAccess[currentIndex].textName : "" }}
        </div>
        <div class="accessDetailBox">
          <span
            class="accessDetailItem"
            v-for="(item, index) in allSkillAccess[currentIndex]
              ? allSkillAccess[currentIndex].child
              : []"
            :key="index"
          >
            <span>{{ item.name }}</span>
            <el-rate v-model="item.score"></el-rate>
          </span>
        </div>

        <div class="btnBox">
          <el-button size="mini" type="primary" @click="saveAccessDetail"
            >保 存</el-button
          >
          <el-button type="primary" size="mini" @click="personAssessVisible = false"
            >取 消</el-button
          >
        </div>
      </el-dialog>

      <!-- 修改信息——企业用户 -->
      <el-dialog :visible.sync="CompanyUserIsShow" width="40%" class="personAssessStyle">
        <h2>修改信息-企业用户</h2>
        <el-form ref="CompanyUserForm" label-width="100px">
          <el-form-item label="用户名">
            <el-input v-model="updateCompanyData.username" disabled></el-input>
          </el-form-item>
          <el-form-item label="公司名称" v-if="updateCompanyData.userInfo">
            <el-input v-model="updateCompanyData.userInfo.enterpriseName"></el-input>
          </el-form-item>
          <el-form-item label="所属行业" v-if="updateCompanyData.userInfo">
            <el-input v-model="updateCompanyData.userInfo.industry"></el-input>
          </el-form-item>
          <el-form-item label="公司性质" v-if="updateCompanyData.userInfo">
            <el-input v-model="updateCompanyData.userInfo.type"></el-input>
          </el-form-item>
          <el-form-item label="联系人" v-if="updateCompanyData.userInfo">
            <el-input v-model="updateCompanyData.userInfo.contactUser"></el-input>
          </el-form-item>
          <el-form-item label="邮箱">
            <el-input v-model="updateCompanyData.email"></el-input>
          </el-form-item>
          <el-form-item label="手机号">
            <el-input v-model="updateCompanyData.telephone"></el-input>
          </el-form-item>
          <el-form-item label="联系地址" v-if="updateCompanyData.userInfo">
            <el-input v-model="updateCompanyData.userInfo.address"></el-input>
          </el-form-item>
          <el-form-item label="开票名称" v-if="updateCompanyData.userInfo">
            <el-input v-model="updateCompanyData.userInfo.billingName"></el-input>
          </el-form-item>
          <el-form-item label="增值税登记号" v-if="updateCompanyData.userInfo">
            <el-input v-model="updateCompanyData.userInfo.taxNo"></el-input>
          </el-form-item>

          <el-form-item>
            <el-button type="primary" @click="saveCompanyUserInfo">保存</el-button>
            <el-button @click="CompanyUserIsShow = false">取消</el-button>
          </el-form-item>
        </el-form>
      </el-dialog>
      <!-- 修改信息——合作伙伴 -->
      <el-dialog
        :visible.sync="CooperUserInfoIsShow"
        width="35%"
        class="personAssessStyle"
      >
        <h2>修改信息-合作伙伴</h2>
        <el-form ref="CooperUserForm" label-width="100px">
          <el-form-item label="企业名称">
            <el-input v-model="updateCooperUserData.username" disabled></el-input>
          </el-form-item>
          <el-form-item label="所属行业" v-if="updateCooperUserData.userInfo">
            <el-input v-model="updateCooperUserData.userInfo.industry"></el-input>
          </el-form-item>
          <el-form-item label="人员规模" v-if="updateCooperUserData.userInfo">
            <el-input v-model="updateCooperUserData.userInfo.staffSize"></el-input>
          </el-form-item>
          <el-form-item label="服务内容" v-if="updateCooperUserData.userInfo">
            <el-input v-model="updateCooperUserData.userInfo.serviceContent"></el-input>
          </el-form-item>
          <el-form-item label="服务产品" v-if="updateCooperUserData.userInfo">
            <el-input v-model="updateCooperUserData.userInfo.serviceProduct"></el-input>
          </el-form-item>
          <el-form-item label="联系地址" v-if="updateCooperUserData.userInfo">
            <el-input v-model="updateCooperUserData.userInfo.address"></el-input>
          </el-form-item>
          <el-form-item label="联系人" v-if="updateCooperUserData.userInfo">
            <el-input v-model="updateCooperUserData.userInfo.name"></el-input>
          </el-form-item>
          <el-form-item label="邮箱">
            <el-input v-model="updateCooperUserData.email"></el-input>
          </el-form-item>
          <el-form-item label="电话">
            <el-input v-model="updateCooperUserData.telephone"></el-input>
          </el-form-item>
          <el-form-item>
            <el-button type="primary" @click="saveCooperUserInfo">保存</el-button>
            <el-button @click="CooperUserInfoIsShow = false">取消</el-button>
          </el-form-item>
        </el-form>
      </el-dialog>
      <!-- 修改信息——合作伙伴的个人顾问 -->
      <el-dialog
        :visible.sync="CooperSelfInfoIsShow"
        width="35%"
        class="personAssessStyle"
      >
        <h2>修改信息-合作伙伴的个人顾问</h2>
        <el-form label-width="100px">
          <el-form-item label="用户名">
            <el-input v-model="updateCompanyUserData.username" disabled></el-input>
          </el-form-item>
          <el-form-item label="姓名">
            <el-input v-model="updateCompanyUserData.name"></el-input>
          </el-form-item>
          <el-form-item label="所在企业">
            <el-input v-model="updateCompanyUserData.cooperName"></el-input>
          </el-form-item>
          <el-form-item label="所在行业">
            <el-input v-model="updateCompanyUserData.industry"></el-input>
          </el-form-item>
          <el-form-item label="出生日期">
            <el-input v-model="updateCompanyUserData.brithday"></el-input>
          </el-form-item>
          <el-form-item label="学历">
            <el-input v-model="updateCompanyUserData.education"></el-input>
          </el-form-item>
          <el-form-item label="毕业院校">
            <el-input v-model="updateCompanyUserData.graduatedFrom"></el-input>
          </el-form-item>
          <el-form-item label="专业">
            <el-input v-model="updateCompanyUserData.major"></el-input>
          </el-form-item>
          <el-form-item label="服务方向">
            <el-input v-model="updateCompanyUserData.serviceDirection"></el-input>
          </el-form-item>
          <el-form-item label="从业经验">
            <el-input v-model="updateCompanyUserData.industryExperience"></el-input>
          </el-form-item>
          <el-form-item label="从业年限">
            <el-input v-model="updateCompanyUserData.bmi_history"></el-input>
          </el-form-item>
          <el-form-item label="擅长领域">
            <el-input v-model="updateCompanyUserData.expertise"></el-input>
          </el-form-item>
          <el-form-item label="邮箱">
            <el-input v-model="updateCompanyUserData.email"></el-input>
          </el-form-item>
          <el-form-item label="手机号">
            <el-input v-model="updateCompanyUserData.telephone"></el-input>
          </el-form-item>

          <el-form-item>
            <el-button type="primary" @click="saveCooperSelfUserInfo">保存</el-button>
            <el-button @click="CooperSelfInfoIsShow = false">取消</el-button>
          </el-form-item>
        </el-form>
      </el-dialog>
      <!-- 修改信息——个人顾问 -->
      <el-dialog :visible.sync="SelfUserInfoIsShow" width="35%" class="personAssessStyle">
        <h2>修改信息-个人顾问</h2>
        <el-form ref="CompanyUserForm" label-width="100px">
          <el-form-item label="用户名">
            <el-input v-model="updatePersonaluserData.username" disabled></el-input>
          </el-form-item>
          <el-form-item label="姓名" v-if="updatePersonaluserData.userInfo">
            <el-input v-model="updatePersonaluserData.userInfo.name"></el-input>
          </el-form-item>
          <el-form-item label="出生日期" v-if="updatePersonaluserData.userInfo">
            <el-input v-model="updatePersonaluserData.userInfo.brithday"></el-input>
          </el-form-item>
          <el-form-item label="学历" v-if="updatePersonaluserData.userInfo">
            <el-input v-model="updatePersonaluserData.userInfo.education"></el-input>
          </el-form-item>
          <el-form-item label="毕业院校" v-if="updatePersonaluserData.userInfo">
            <el-input v-model="updatePersonaluserData.userInfo.graduatedFrom"></el-input>
          </el-form-item>
          <el-form-item label="专业" v-if="updatePersonaluserData.userInfo">
            <el-input v-model="updatePersonaluserData.userInfo.major"></el-input>
          </el-form-item>
          <el-form-item label="服务行业" v-if="updatePersonaluserData.userInfo">
            <el-input
              v-model="updatePersonaluserData.userInfo.serviceDirection"
            ></el-input>
          </el-form-item>
          <el-form-item label="从业经验" v-if="updatePersonaluserData.userInfo">
            <el-input
              v-model="updatePersonaluserData.userInfo.industryExperience"
            ></el-input>
          </el-form-item>
          <el-form-item label="从业年限" v-if="updatePersonaluserData.userInfo">
            <el-input v-model="updatePersonaluserData.userInfo.bmiHistory"></el-input>
          </el-form-item>
          <el-form-item label="擅长领域" v-if="updatePersonaluserData.userInfo">
            <el-input v-model="updatePersonaluserData.userInfo.expertise"></el-input>
          </el-form-item>
          <el-form-item label="邮箱">
            <el-input v-model="updatePersonaluserData.email"></el-input>
          </el-form-item>
          <el-form-item label="手机号">
            <el-input v-model="updatePersonaluserData.telephone"></el-input>
          </el-form-item>
          <el-form-item>
            <el-button type="primary" @click="saveSelfUserInfo">保存</el-button>
            <el-button @click="SelfUserInfoIsShow = false">取消</el-button>
          </el-form-item>
        </el-form>
      </el-dialog>
    </div>
  </div>
</template>

<script>
import axios from "axios";
import SelfTitle from "@/components/SelfTitle.vue";
import {
  ReqEnterPriseUser,
  ReqCooperativeUser,
  ReqPersonalUser,
  ReqProhibitUser,
  ReqDeleteUser,
  ReqCooperPersonUser,
  ReqEnterpriseScored,
  ReqPersonalScored,
  ReqPersonal,
  ReqInforoId,
  ReqEnterpriseuserUpdate,
  ReqCooperativeuserUpdate,
  ReqPersonaluserUpdate,
} from "../../../request";
import abilityText from "../../../utils/abilityText.json";
export default {
  data() {
    return {
      enterpriseData: [],
      smEnterpriseData: [],
      cooperativeData: [],
      smCooperativeData: [],
      personaluserData: [],
      smPersonaluserData: [],
      allCooperPersonData: [],
      smAllCooperPersonData: [],
      isShowMoreStatus: [
        { isShow: false },
        { isShow: false },
        { isShow: false },
        { isShow: false },
      ],
      companyAssessVisible: false,
      companyAssessTitle: [
        { title: "评测点1", value: 3 },
        { title: "评测点2", value: 2 },
        { title: "评测点3", value: 3 },
        { title: "评测点4", value: 5 },
        { title: "评测点5", value: 2 },
        { title: "评测点6", value: 1 },
        { title: "评测点7", value: 4 },
        { title: "评测点8", value: 2 },
        { title: "评测点9", value: 3 },
        { title: "评测点10", value: 3 },
      ],
      personAssessVisible: false,
      screenWidth: 0,
      // 保存企业用户的id
      enterpriseId: "",
      // 当前选中的技能
      currentIndex: 0,
      // 全部技能
      allSkillAccess: [],
      // 保存个人顾问用户的id
      personalId: "",
      userType: "",
      username: "hhhh",
      // 修改用户信息
      CompanyUserIsShow: false,
      CooperUserInfoIsShow: false,
      CooperSelfInfoIsShow: false,
      SelfUserInfoIsShow: false,
      updateCompanyData: {},
      updateCooperUserData: {},
      updateCompanyUserData: {},
      updatePersonaluserData: {},
    };
  },
  components: {
    SelfTitle,
  },
  methods: {
    async deleteManageUser(id) {
      this.$confirm("此操作将永久删除该用户, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(async () => {
          await ReqDeleteUser([id]);
          this.$message({
            type: "success",
            message: "删除成功!",
          });
          await this.getAllPersonData();
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消删除",
          });
        });
    },
    // 修改状态
    async findShopFans(id, status) {
      console.log(id, status);
      let result = await ReqProhibitUser({ id, status });
      const { msg } = result;
      if (msg === "success") {
        this.$message({
          message: "修改用户状态成功",
          type: "success",
        });
        await this.getAllPersonData();
      }
    },
    // 点击查看需求
    seeReq() {
      this.$router.history.push("/self/manage/ManReqAll");
    },
    // 点击企业评分
    companyAssess(id) {
      this.enterpriseId = id;
      this.companyAssessVisible = true;
    },
    // 个人评分
    personAssess(id) {
      this.personalId = id;
      console.log(id);
      this.personAssessVisible = true;
    },
    // 进入更多信息的详情
    enterMoreUserInfo(id, type) {
      this.$router.history.push(`/self/manage/userDetailInfoMobel?id=${id}&type=${type}`);
    },
    // 查询全部的企业用户
    async getAllEnterPriseuser() {
      let resultData = await ReqEnterPriseUser();
      let {
        page: { list },
      } = resultData;
      this.enterpriseData = list;
      this.smEnterpriseData = this.enterpriseData.slice(0, 5);
      console.log("企业用户", this.enterpriseData);
    },
    // 获取合作伙伴
    async getAllCooperative() {
      let resultData = await ReqCooperativeUser();
      let {
        page: { list },
      } = resultData;
      this.cooperativeData = list;
      this.smCooperativeData = this.cooperativeData.slice(0, 5);
      console.log("合作伙伴用户", this.cooperativeData);
    },
    // 获取本公司个人顾问
    async getPersonalUser() {
      let resultData = await ReqPersonal({ id: 1 });
      let {
        data: { personalUserEntities },
      } = resultData;
      this.personaluserData = personalUserEntities.filter(function (item) {
        return item !== null;
      });
      this.smPersonaluserData = this.personaluserData.slice(0, 5);
      console.log("本公司个人顾问", this.personaluserData);
    },
    // 查询企业用户下面的个人用户
    async getCooperPersonUser() {
      const resultData = await ReqCooperPersonUser();
      const { pg } = resultData;
      let allCooperPersonData = [];
      pg.forEach((item) => {
        let cooperName = item.name;
        let cooperIndustry = item.industry;
        item.personalUserEntities.forEach((it) => {
          const { userInfo } = it;
          userInfo.status = it.status;
          userInfo.id = it.id;
          userInfo.email = it.email;
          userInfo.telephone = it.telephone;
          userInfo.username = it.username;
          userInfo.cooperName = cooperName;
          userInfo.industry = cooperIndustry;
          allCooperPersonData.push(userInfo);
        });
      });
      this.allCooperPersonData = allCooperPersonData;
      console.log(this.allCooperPersonData);
      this.smAllCooperPersonData = this.allCooperPersonData.slice(0, 5);
    },
    // 获取全部信息
    async getAllPersonData() {
      await this.getAllEnterPriseuser();
      await this.getAllCooperative();
      await this.getPersonalUser();
      await this.getCooperPersonUser();
    },
    // 查看更多
    seeMore(id) {
      console.log(id);
      console.log("11", !this.isShowMoreStatus[id].isShow);
      this.isShowMoreStatus[id].isShow = !this.isShowMoreStatus[id].isShow;
    },
    // 保存企业用户评分
    async saveCompanyAccess() {
      const addEnterPriseData = {
        createdId: 1,
        scoredId: this.enterpriseId,
        scoreDetails: JSON.stringify({
          score: this.companyAssessTitle,
        }),
      };
      const resultData = await ReqEnterpriseScored(addEnterPriseData);
      const { code } = resultData;
      if (code === 0) {
        this.$message({
          type: "success",
          message: "评分成功!",
        });
      }
      this.companyAssessVisible = false;
    },
    // 处理个人顾问评分
    dealPersonAssess() {
      const allSkillAccess = abilityText.text;
      this.allSkillAccess = allSkillAccess;
    },
    // 修改用户信息
    async motifyUserInfo(id, type) {
      switch (type) {
        case 1:
          this.CompanyUserIsShow = true;
          this.updateCompanyData = this.enterpriseData.filter(
            (item) => item.id === id
          )[0];
          break;
        case 2:
          this.CooperUserInfoIsShow = true;
          this.updateCooperUserData = this.cooperativeData.filter(
            (item) => item.id === id
          )[0];
          console.log(this.cooperativeData);
          break;
        case 3:
          this.CooperSelfInfoIsShow = true;
          this.updateCompanyUserData = this.allCooperPersonData.filter(
            (item) => item.id === id
          )[0];
          console.log(this.allCooperPersonData);
          break;
        default:
          this.SelfUserInfoIsShow = true;
          this.updatePersonaluserData = this.personaluserData.filter(
            (item) => item.id === id
          )[0];
          console.log(this.updatePersonaluserData);
      }
    },
    // 保存更改企业用户信息
    async saveCompanyUserInfo() {
      const saveData = this.updateCompanyData.userInfo;
      const { msg } = await ReqEnterpriseuserUpdate(saveData);
      if (msg === "success") {
        this.$message({
          type: "success",
          message: "修改成功",
        });
      }
      this.CompanyUserIsShow = false;
      this.getAllEnterPriseuser();
    },
    // 保存修改的合作伙伴用户信息
    async saveCooperUserInfo() {
      const saveData = this.updateCooperUserData.userInfo;
      console.log(saveData);
      const { msg } = await ReqCooperativeuserUpdate(saveData);
      if (msg === "success") {
        this.$message({
          type: "success",
          message: "修改成功",
        });
      }
      this.CooperUserInfoIsShow = false;
      this.getAllCooperative();
    },
    // 保存修改合作伙伴的个人顾问信息
    async saveCooperSelfUserInfo() {
      const saveData = this.updateCompanyUserData;
      const { msg } = await ReqPersonaluserUpdate(saveData);
      if (msg === "success") {
        this.$message({
          type: "success",
          message: "修改成功",
        });
      }
      this.CooperSelfInfoIsShow = false;
      this.getCooperPersonUser();
    },
    // 保存个人顾问信息
    async saveSelfUserInfo() {
      const saveData = this.updatePersonaluserData.userInfo;
      console.log("saveData:", saveData);
      const { msg } = await ReqPersonaluserUpdate(saveData);
      if (msg === "success") {
        this.$message({
          type: "success",
          message: "修改成功",
        });
      }
      this.SelfUserInfoIsShow = false;
      this.getPersonalUser();
    },
    // 选择具体的评分
    checkDetailAccess(index) {
      this.currentIndex = index;
    },
    // 保存具体的评分信息
    async saveAccessDetail() {
      const data = {
        createdId: 1,
        scoreDetails: JSON.stringify({ score: this.allSkillAccess }),
        scoredId: this.personalId,
      };
      console.log(data);
      const resultInfo = await ReqPersonalScored(data);
      const { code } = resultInfo;
      if (code === 0) {
        this.$message({
          type: "success",
          message: "评分成功",
        });
      }
      this.personAssessVisible = false;
    },
    //查看项目
    enterProject() {
      this.$router.history.push(`/self/manage/projectAll`);
    },
    // 导出用户
    exportUser(url, exportName) {
      axios({
        method: "get", // 请求方式
        url, // 请求地址
        responseType: "arraybuffer", // 重点，请求的数据类型   
      })
        .then((response) => {
          /* 兼容ie内核，360浏览器的兼容模式 */
          if (window.navigator && window.navigator.msSaveOrOpenBlob) {
            let blob = new Blob([response.data]);
            window.navigator.msSaveOrOpenBlob(blob, `${exportName}.xls`);
          } else {
            /* 火狐谷歌的文件下载方式 */
            var blob = new Blob([response.data]);
            var downloadElement = document.createElement("a");
            var href = window.URL.createObjectURL(blob);
            downloadElement.href = href;
            downloadElement.download = `${exportName}.xls`;
            document.body.appendChild(downloadElement);
            downloadElement.click();
            document.body.removeChild(downloadElement);
            window.URL.revokeObjectURL(href);
          }
        })
        .catch((response) => {
          console.log(response);
        });
    },
    // 创建用户
    createUser() {
      this.$router.history.push(`/self/manage/addManage`);
    },
  },
  async created() {
    this.userType = sessionStorage.getItem("userType");
    this.username = this.userType == 13 ? "超级管理用户" : "管理用户";
    await this.getAllPersonData();
    this.dealPersonAssess();
  },
};
</script>

<style scoped>
@import url("~@/assets/styles/manage/user.css");
.isShow {
  display: none;
}

.isChecked {
  color: #f0ab00;
}
.accessDetailTitle {
  text-align: center;
  font-size: 18px;
  line-height: 40px;
}
.accessDetailBox {
  display: flex;
  flex-wrap: wrap;
}
.accessDetailItem {
  width: 50%;
  display: flex;
  line-height: 30px;
}
.accessDetailItem :nth-child(1) {
  flex: 2;
  color: #ccc;
}
.accessDetailItem :nth-child(2) {
  flex: 1;
}
</style>
